obj = require('./compile_sol.js')

//部署
account = '0xd6cc4024572ca10bffbb0d1802e1991608ad665f';
Web3 = require('web3');
web3 = new Web3();
web3.setProvider('http://localhost:8546');

var gasInfo = {
    from: account,
    gas: 1500000,
    gasPrice: '1'
};


myContract = new web3.eth.Contract(obj.abi);
myContract
    .deploy({data: '0x' + obj.bytecode,})
    .send(gasInfo)
    .on('transactionHash', function (transactionHash) {
        console.log("transactionHash: ", transactionHash)
    })
    .then(myContractInstance => {
        console.log("contract addr: ", myContractInstance.options.address + " deploy success!!");

        var gasInfo2 = {
            from: account,
            gas: 1500000,
            gasPrice: '1'
        };
        myContractInstance.methods.callTestContract(9, 15)
            .send(gasInfo2, function (err, res) {
                console.log("callTestContract: ", res);
            })
            .on('receipt', function (receipt) {
                myContractInstance.methods.bts().call(function (err, res) {
                    console.log("bts res: ", res);
                })
            });

        console.log("contract event end");
    });

